<!--  -->
<template>
  <div />
</template>

<script setup>
import usePermissionStore from '@/store/modules/permission'
import { useRouter } from 'vue-router'
const usePerStore = usePermissionStore()
const addRoutes = usePerStore.addRoutes
const router = useRouter()
const handleToHome = () => {
  try {
    if (addRoutes.length) {
      const curRouter = addRoutes[0]
      const curPath = curRouter.path
      const curChildRouter = curRouter.children && curRouter.children[0]
      let toPath
      if (curChildRouter) {
        const curChildPath = curChildRouter.path
        toPath = curPath + '/' + curChildPath
      } else {
        toPath = curPath
      }

      router.replace(toPath).catch(() => {})
    } else {
      router.replace('/404').catch(() => {})
    }
  } catch (e) {
    console.log(e)
  }
}
handleToHome()
</script>

<style lang="scss" scoped></style>
